﻿function isIE() {
    if (!!window.ActiveXObject || "ActiveXObject" in window)
        return true;
    else
        return false;
}
function GetHeight() {
    var h = window.innerHeight;
    if (typeof h != "number") {
        if (document.compatMode == "number") {
            h = document.documentElement.clientHeight;
        } else {
            h = document.body.clientHeight;
        }
    }
    return h;
}

function GetWidth() {
    var w = window.innerWidth;
    if (typeof w != "number") {
        if (document.compatMode == "number") {
            w = document.documentElement.clientWidth;
        } else {
            w = document.body.clientWidth;
        }
    }
    return w;
}

function funDown(url) {
    try {
        var elemIF = document.createElement("iframe");
        elemIF.src = url;
        elemIF.style.display = "none";
        document.body.appendChild(elemIF);
    } catch (e) {

    }
}

function PrintImg() {
    var newstr = "<img alt=\"\" src=\"" + $("#viewer img").attr("src") + "\" style=\"max-width:100%;max-height:100%;\" />";
    printWindow = window.open();
    printWindow.document.write(newstr);
    printWindow.print();//谷歌打印
    return false;
}

function PrintSetting() {
    var href = location.href.toLowerCase();
    if (href.indexOf("/See.aspx".toLowerCase()) != -1) {
        var FID = QueryString("FID");
        var PID = $("a.jstree-clicked").attr("PageID");
        showPage("案卷打印/导出PDF", "/FilesPrint.aspx?FID=" + FID + "&PID=" + PID, 410, 345, false);
    }
    else if (href.indexOf("/ImgOrder.aspx".toLowerCase()) != -1) {
        var FID = $("#mytable2 tbody tr.selected").attr("value");
        var PID = $("#mytable3 tbody tr.selected").attr("fileid");
        showPage("案卷打印/导出PDF", "/FilesPrint.aspx?FID=" + FID + "&PID=" + PID, 410, 345, false);
    }
    else if (href.indexOf("/IndexMount.aspx".toLowerCase()) != -1) {
        var FID = $("#Select_type").val();
        var PID = $("#mytable3 tbody tr.selected").attr("PageID");
        showPage("案卷打印/导出PDF", "/FilesPrint.aspx?FID=" + FID + "&PID=" + PID, 410, 345, false);
    }
    else {
        PrintImg();
    }
}

///黑白打印   不好用
function PrintSettingForBlackWhite() {
    var href = location.href.toLowerCase();
    if (href.indexOf("/See.aspx".toLowerCase()) != -1) {
        var FID = QueryString("FID");
        var PID = $("a.jstree-clicked").attr("PageID");
        showPage("黑白打印/导出PDF", "/FilesPrintToBlackWhite.aspx?FID=" + FID + "&PID=" + PID, 400, 300, false);
    }
    else if (href.indexOf("/ImgOrder.aspx".toLowerCase()) != -1) {
        var FID = $("#mytable2 tbody tr.selected").attr("value");
        var PID = $("#mytable3 tbody tr.selected").attr("fileid");
        showPage("黑白打印/导出PDF", "/FilesPrintToBlackWhite.aspx?FID=" + FID + "&PID=" + PID, 400, 300, false);
    }
    else if (href.indexOf("/IndexMount.aspx".toLowerCase()) != -1) {
        var FID = $("#Select_type").val();
        var PID = $("#mytable3 tbody tr.selected").attr("PageID");
        showPage("黑白打印/导出PDF", "/FilesPrintToBlackWhite.aspx?FID=" + FID + "&PID=" + PID, 400, 300, false);
    }
    else {
        PrintImg();
    }
}

function ChangePdf() {
    var _OldPath = $("#viewer img").attr("src");

    $.ajax({
        type: "post",
        url: "/ashx/EditData.ashx",
        dataType: "json",
        async: false,
        data: { Type: "ChangePdf", OldPath: _OldPath },
        success: function (msg) {
            if (msg.result == 1) {
                window.open(msg.PdfPath);
            }
        }
    });
}

//显示遮罩和提示信息
function DataLoading() {
    var mTop = (window.innerHeight - 80) / 2;
    var htmlTip = "<div id=\"htmlTip\">";
    htmlTip += "<div style=\"position:fixed;z-index:100005;width:100%;height:100%;top:0px; background:#000;opacity:0.6; \"></div>";
    htmlTip += "<div style=\"position:fixed;z-index:100006;width:100%;font-size:16px;text-align:center;top:" + mTop + "px;\">";
    htmlTip += "<div class=\"sk-spinner sk-spinner-cube-grid\" style=\"width:30px;height:30px;line-height:30px;margin:0 auto;\"><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div></div>";
    htmlTip += "</div>";

    htmlTip += "</div>";
    $("body").append(htmlTip);
}

//显示遮罩和提示信息
function DataLoading2(TipMsg) {
    var mTop = (window.innerHeight - 80) / 2;
    var htmlTip = "<div id=\"htmlTip\">";
    htmlTip += "<div style=\"position:fixed;z-index:100005;width:100%;height:100%;top:0px; background:#fff;opacity:0.6; \"></div>";
    htmlTip += "<div style=\"position:fixed;z-index:100006;width:100%;font-size:16px;text-align:center;top:" + mTop + "px;\">";
    htmlTip += "<div class=\"sk-spinner sk-spinner-cube-grid\" style=\"width:30px;height:30px;line-height:30px;margin:0 auto;\"><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div><div class=\"sk-cube\"></div></div>";
    htmlTip += "</div>";

    htmlTip += "</div>";
    $("body").append(htmlTip);
}


//msg提示信息 callback回调函数
function _Confirm(msg, okScript, cancelScript) {
    //$("#confirmModal").remove();//清除原有html，防止出现多个confirm

    parent.layer.confirm(msg, {
        icon: 3,
        skin: 'layui-layer-molv',
        btn: ['确定', '取消'] //按钮
    }, function (index) {
        okScript.call(this.okScript);//确认时执行的回调函数
        parent.layer.close(index); //疯狂模式，关闭所有层
    }, function (index) {
        if (cancelScript != null) {
            cancelScript.call(this.cancelScript);//取消时执行的回调函数
        }
        parent.layer.close(index); //疯狂模式，关闭所有层
    });

    //设置删除对话框的快捷键 
    SetPublicHotKey();
}

//删除数据 通用方法
function DelData(_url,_TabName, _ColID, scripts) {
    $.ajax({
        type: "post",
        url: _url,
        dataType: "json",
        async: true,
        data: { TabName: _TabName, ColID: _ColID },
        success: function (msg) {
            if (msg > 0) {
                var _LogInfo = $("#hfLogInfo").val();
                var _Modular = $("#hfModular").val();
                var _PageUrl = $("#hfPageUrl").val();

                AddLog(_LogInfo, _Modular, _PageUrl);

                if (scripts != undefined) {
                    scripts.call(this.scripts);
                }
                else {
                    location.href = location.href;
                }
            }
        }
    });
}

function AddLog(_LogInfo, _Modular, _PageUrl) {
    $.ajax({
        type: "post",
        url: "/ashx/EditData.ashx",
        dataType: "json",
        async: false,
        cache: false,
        data: { type: "AddLog", LogInfo: _LogInfo, Modular: _Modular, PageUrl: _PageUrl },
        success: function (msg) { }
    });
}

//TabName表名 ParName字段名 ParVal值
function ChangeState(_url, _TabName, _ID, _ParName, _ParVal, scripts) {
    $.ajax({
        type: "post",
        url: _url,
        dataType: "json",
        async: true,
        data: { 'TabName': _TabName, 'ID': _ID, 'ParName': _ParName, 'ParVal': _ParVal },
        success: function (msg) {
            if (msg > 0) {
                if (scripts != undefined) {
                    scripts.call(this.scripts);
                }
                else {
                    location.href = location.href;
                }
            }
        }
    });
}
function ChangeState_EditID(_TabName, _ID, _ParName, _ParVal) {
    $.ajax({
        type: "post",
        url: "/ashx/EditData.ashx",
        dataType: "json",
        async: false,
        data: { Type: "ChangeState", TabName: _TabName, ID: _ID, ParName: _ParName, ParVal: _ParVal },
        success: function (msg) {
            if (msg.result > 0) {
                location.href = location.href;
            }
        }
    });
}
//TabName表名 ParName字段名 ParVal值
function ChangeState_IsUndergo(_TabName, _ID, _ParName, _ParVal) {
    _Confirm("确定要改变该人员在职状态吗？离岗状态将不可登录！", function () {
        $.ajax({
            type: "post",
            url: "/ashx/EditData.ashx",
            dataType: "json",
            async: false,
            data: { Type: "ChangeState", TabName: _TabName, ID: _ID, ParName: _ParName, ParVal: _ParVal },
            success: function (msg) {
                if (msg.result > 0) {
                    location.href = location.href;
                }
            }
        });
    })
}



//TabName表名 ParName字段名 ParVal值
function ChangeState_IsShow(_TabName, _ID, _ParName, _ParVal) {
    _Confirm("是否要修改当前栏目的隐藏或显示状态", function () {
        $.ajax({
            type: "post",
            url: "/ashx/EditData.ashx",
            dataType: "json",
            async: false,
            data: { Type: "ChangeState", TabName: _TabName, ID: _ID, ParName: _ParName, ParVal: _ParVal },
            success: function (msg) {
                if (msg.result > 0) {
                    location.href = location.href;
                }
            }
        });
    })
}

$(function () {
    $(".btn-pd").click(function () {
        if ($("#tabData tbody tr").hasClass("selected") == false) {
            showTip("请选择案卷!", 2, 0)
        }
    })

    //SetAnimate();

    //$(".i-checks").iCheck({ checkboxClass: "icheckbox_square-green", radioClass: "iradio_square-green", })
    //layer.config({
    //    skin: 'layui-layer-molv'
    //})

    //var ContentHeight = document.documentElement.clientHeight - 184;
    //$(".ibox>.ibox-content").height(ContentHeight);
    //$(".wrapper-content").children(".ibox").children(".ibox-content").height(ContentHeight);

    $("input[type='text']").attr("autocomplete", "off");//文本框不缓存

    if ($(".zui-footer").length > 0) {
        //$("#dContent").height($("form").height() - 65);
        $("#dContent .input-group:last()").css({ "margin-bottom": "0px" });
    }


    var ContentHeight = document.documentElement.clientHeight - 68;
    var hrefLocation = location.href.toLowerCase();
    if (hrefLocation.indexOf("/homepage") == -1 && hrefLocation.indexOf("/search.aspx?wd=") == -1) {
        $(".ibox>.ibox-content").css({ "height": ContentHeight + "px", "overflow-y": "auto" });
    }

    $(".show-messager").on("click", function () {
        var $this = $(this);
        var data = $this.data("zui.messager");
        var options = $this.data();
        $this.data("zui.messager", $.zui.messager.show(options.content, options));
    });

    SetPublicHotKey();

    //setPanel();

    var url = location.href.toLowerCase();
    if (url.indexOf("/IndexMount.aspx".toLowerCase()) != -1) { SetIndexMount(); }
    if (url.indexOf("/ImgOrder.aspx".toLowerCase()) != -1) { SetImgOrder(); }
    if (url.indexOf("/ImgOrderAB.aspx".toLowerCase()) != -1) { SetImgOrderAB(); }
    if (url.indexOf("/ImgBeautify.aspx".toLowerCase()) != -1 || url.indexOf("/ImgCheck.aspx".toLowerCase()) != -1) { SetImgProcess(); }
    if (url.indexOf("/ImgGetFrame1.aspx".toLowerCase()) != -1) { SetImgGetFrame1(); }
    if (url.indexOf("/ImgGetFrame1_2.aspx".toLowerCase()) != -1) { SetImgGetFrame1_2(); }
    if (url.indexOf("/ImgGetFrame1_3.aspx".toLowerCase()) != -1) { SetImgGetFrame1_3(); }
    if (url.indexOf("/ImgGetFrame1_4.aspx".toLowerCase()) != -1) { SetImgGetFrame1_4(); }
    if (url.indexOf("/scan10/VolumeDir.aspx".toLowerCase()) != -1) { SetVolumeDir10(); }
    if (url.indexOf("/ImgGetFrame2.aspx".toLowerCase()) != -1) { SetImgGetFrame2(); }
    if (url.indexOf("/ImgGetFrame3.aspx".toLowerCase()) != -1) { SetImgGetFrame3(); }
    if (url.indexOf("/scan1/VolumeDir.aspx".toLowerCase()) != -1) { SetVolumeDir1(); }
    if (url.indexOf("/scan1/Party.aspx".toLowerCase()) != -1) { SetVolumeDir1(); }
    if (url.indexOf("/scan2/VolumeDir.aspx".toLowerCase()) != -1) { SetVolumeDir2(); }
    if (url.indexOf("/ImageSon.aspx".toLowerCase()) != -1) { SetImageSon(); }
    if (url.indexOf("/SeeImage.aspx".toLowerCase()) != -1) { SetSeeImage(); }
    if (url.indexOf("/TreStatistics.aspx".toLowerCase()) != -1) { SetTreStatistics(); }
    if (url.indexOf("/CaseStatistics.aspx".toLowerCase()) != -1) { SetCaseStatistics(); }
    //if (url.indexOf("/ABVersions/ImgNameEditTC.aspx".toLowerCase()) != -1) { ImgNameEditTC(); }

    //var _fn = function () {
    //    //setPanel();
    //    if (url.indexOf("/IndexMount.aspx".toLowerCase()) != -1) { SetIndexMount(); }
    //    if (url.indexOf("/ImgOrder.aspx".toLowerCase()) != -1) { SetImgOrder(); }
    //    if (url.indexOf("/ImgBeautify.aspx".toLowerCase()) != -1 || url.indexOf("/ImgCheck.aspx".toLowerCase()) != -1) { SetImgProcess(); }
    //    if (url.indexOf("/ImgGetFrame1.aspx".toLowerCase()) != -1) { SetImgGetFrame1(); }
    //    if (url.indexOf("/ImgGetFrame2.aspx".toLowerCase()) != -1) { SetImgGetFrame2(); }
    //    if (url.indexOf("/ImgGetFrame3.aspx".toLowerCase()) != -1) { SetImgGetFrame3(); }
    //    if (url.indexOf("/VolumeDir.aspx".toLowerCase()) != -1) { SetVolumeDir(); }
    //    if (url.indexOf("/ImageSon.aspx".toLowerCase()) != -1) { SetImageSon(); }
    //    if (url.indexOf("/SeeImage.aspx".toLowerCase()) != -1) { SetSeeImage(); }
    //    if (url.indexOf("/TreStatistics.aspx".toLowerCase()) != -1) { SetTreStatistics(); }
    //    if (url.indexOf("/CaseStatistics.aspx".toLowerCase()) != -1) { SetCaseStatistics(); }
    //};
    //onWindowResize.add(_fn);
})


//提示消息
function showTip(message, iconType, hideType, myScripts) {
    //icon 1正确 2错误 3问号 4锁定 5哭脸 6笑脸 7下载 8 感叹号
    parent.layer.msg(message, { icon: iconType, time: 1500 }, function () {
        if (myScripts != null) {
            myScripts.call(this.myScripts);//执行自定义方法
        }

        if (hideType == 1) {
            location.href = location.href;
        }
        else if (hideType == 2) {
            window.parent.$(".layui-layer-close").click();
        }
        else if (hideType == 3) {
            window.location.target = "_ablank";
            window.top.location.href = "Home/HomePage";
        }
        else if (hideType == 4) {
            window.top.location.href = "/Login";
        }
        else if (hideType == 5) {
            //有属性菜单专用，无刷新更新右侧表格数据
            window.parent.$("iframe.J_iframe:visible").contents().find("a.jstree-clicked").click();
            closePage();
        }
    });
}
//弹出页面 标题，链接，宽度，高度，是否在关闭的时候刷新页面
function showPagea(pageTitle, pageUrl, pageWidth, pageHeight, isRef, scripts) {
    parent.layer.open({
        type: 2,
        area: [pageWidth + "px", pageHeight + "px"],
        fixed: false, //不固定
        maxmin: false,
        title: pageTitle,
        content: "../" + pageUrl,
        success: function (layero, index) {
            $(".layui-layer-iframe iframe").focus();//给iframe焦点
        },
        cancel: function (index) {
            if (isRef) {
                location.href = location.href;
            }
            else {
                if (scripts != undefined) {
                    scripts.call(this.scripts);
                }
            }
        }
    });
}


//弹出页面 标题，链接，宽度，高度，是否在关闭的时候刷新页面
function showPage(pageTitle, pageUrl, pageWidth, pageHeight, isRef, scripts) {
    parent.layer.open({
        type: 2,
        area: [pageWidth + "px", pageHeight + "px"],
        fixed: false, //不固定
        maxmin: false,
        resize: false,
        title: pageTitle,
        content: pageUrl,
        success: function (layero, index) {
            $(".layui-layer-iframe iframe").focus();//给iframe焦点
        },
        cancel: function (index) {
            if (isRef) {
                location.href = location.href;
            }
            else {
                if (scripts != undefined) {
                    scripts.call(this.scripts);
                }
            }
        }
    });
}

//数据挂接用
//弹出页面 标题，链接，宽度，高度，是否在关闭的时候刷新页面
function showPages(pageTitle, pageUrl, pageWidth, pageHeight, isRef, scripts) {
    parent.layer.open({
        type: 2,
        area: [pageWidth + "px", pageHeight + "px"],
        fixed: false, //不固定
        maxmin: false,//最大最小化按钮
        title: pageTitle,
        content: pageUrl,
        success: function (layero, index) {
            $(".layui-layer-iframe iframe").focus();//给iframe焦点
        },
        cancel: function (index) {
            if (!isRef) {
                location.href = location.href;
            }
            else {
                if (scripts != undefined) {
                    scripts.call(this.scripts);
                }
            }
        }
    });
}

//音视频 播放视频可最大化最小化
function showPageforMP4(pageTitle, pageUrl, pageWidth, pageHeight, isRef, scripts) {
    parent.layer.open({
        type: 2,
        area: [pageWidth + "px", pageHeight + "px"],
        fixed: false, //不固定
        maxmin: true,//最大最小化按钮
        resize: true,
        title: pageTitle,
        content: pageUrl,
        success: function (layero, index) {
            $(".layui-layer-iframe iframe").focus();//给iframe焦点
        },
        resizing: function (layero) {
            alert(123);
            console.log(layero);
        } ,
        cancel: function (index) {
            if (!isRef) {
                location.href = location.href;
            }
            else {
                if (scripts != undefined) {
                    scripts.call(this.scripts);
                }
            }
        }
    });
}

function showFullPage(pageTitle, pageUrl, scripts) {
    layer.open({
        type: 2,
        title: pageTitle,
        content: pageUrl,
        maxmin: false,
        area: ["100%", "100%"]
    });
}

function ShowDivOfPage(DivDom, DivTitle, PageWidth, PageHeight) {
    layer.open({
        type: 1,
        area: [PageWidth + "px", PageHeight + "px"],
        title: DivTitle,
        content: $(DivDom)
    });
}


function closePage() {
    //var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    //parent.layer.close(index); //再执行关闭   
    //window.parent.$(".layui-layer-close").click();

    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    parent.layer.close(index); //再执行关闭   
}

function CloseDiv() {
    $(".layui-layer-close").click();
}



//设置myPanel的宽度
//function setPanel() {
//    var hrefStr = location.href.toLowerCase();
//    var w1 = GetWidth();
//    var h1 = GetHeight();

//    var h2 = $("#header").height();
//    var h3 = $("#foot").height();
//    var h4 = h1 - h2 - h3 - 112;
//    var h5 = h4 + 60;
//    var h6 = (h4 - $(".alert").height() - 10) / 2;

//    var w2 = $("#primaryNavbar").width();
//    w2 = w2 == null ? 0 : w2;
//    var w3 = w1 - w2 - 12;

//    $("#myPanel>.panel-body").height(h4);
//    $("#primaryNavbar").height(h5);

//    if (hrefStr.indexOf("/Instruments.aspx".toLowerCase()) != -1) { $(".alert").css("margin-top", h6); }
//    if (hrefStr.indexOf("/scan3/index.aspx".toLowerCase()) != -1) { $(".alert").css("margin-top", h6); }
//    if (hrefStr.indexOf("/scan4/index.aspx".toLowerCase()) != -1) { $(".alert").css("margin-top", h6); }
//    if (hrefStr.indexOf("/scan5/index.aspx".toLowerCase()) != -1) { $(".alert").css("margin-top", h6); }
//    if (hrefStr.indexOf("/VolPaperPrint.aspx".toLowerCase()) != -1) { $("#myPanel>.panel-body").height(h1 - h2 - h3 - 58); }
//    if (hrefStr.indexOf("/VolumeDir.aspx".toLowerCase()) != -1) { $("#myPanel>.panel-body").height(h1 - h2 - h3 - 58); }

//    //表格
//    if (hrefStr.indexOf("/Litigation.aspx".toLowerCase()) != -1) { $("#dTab").height(h4 - 90); }
//    if (hrefStr.indexOf("/InsSearch1.aspx".toLowerCase()) != -1) { $("#dTab").height(h4 - 90); }
//    if (hrefStr.indexOf("/InsSearch2.aspx".toLowerCase()) != -1) { $("#dTab").height(h4 - 90); }


//    $("#myPanel").width(w3);
//}

function SetIndexMount() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    var h2 = $(".dLeft_top").height();
    var h3 = $("#tab_Head").height();
    var h4 = $("#tab_Body").height();
    var h5 = $("#dInput").height();
    var hh1 = h1 - h2 - h3 - h4 - h5 - 62;
    var hh2 = h1 - 71;
    var hh3 = h1 - 10;

    var w2 = $("#primaryNavbar").width();
    var w3 = $("#dLeft").width();
    var w4 = $("#dCenter").width();
    var ww1 = w1 - w2 - w3 - w4 - 22;
    $("#dRight").width(ww1);
    $("#dCol").height(hh1);
    $(".div_height").height(hh2);
    $("#dRight").height(hh3);
    $("#viewer").height(hh3).width(w1 - w3 - w4 - 22);
}

function SetImgOrder() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    var w2 = $("#dLeft").width();
    var h2 = $(".dLeft_top").height();
    var h3 = $("#dmidden").height();
    var h4 = h1 - h2 - h3 - 54;

    var h5 = $("#header").height();
    var h6 = $("#foot").height();
    var h7 = h1 - h5 - h6 - 8;

    $("#dImgList").height(h4);
    $("#dLeft").height(h7 - 2);
    $("#div_r").height(h7 - 2).width(w1 - 385);
    $("#viewer").height(h7 - 2).width(w1 - 385);
}
function SetImgOrderAB() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    var w2 = $("#dLeft").width();
    var h2 = $(".dLeft_top").height();
    var h3 = $("#dmidden").height();
    var h4 = h1 - h2 - h3 - 54;

    var h5 = $("#header").height();
    var h6 = $("#foot").height();
    var h7 = h1 - h5 - h6 - 8;

    $("#dImgList").height(h4);
    $("#dLeft").height(h7 - 2);
    $("#div_r").height(h7 - 2).width(w1 - 385);
    $("#viewer").height(h7 - 2).width(w1 - 385);
}


function SetImgProcess() {
    var w1 = GetWidth();
    var h1 = GetHeight();
    var w2 = $("#dSearch").width();
    var h2 = $("#dSearch").height();
    var h3 = $("#bodyDir").height();
    var h4 = h1 - h2 - h3 - 98;
    var h5 = h1 - 52;
    $("#bodyImg").height(h4);
    $("#dRight").height(h5).width(w1 - w2 - 18);
}

function SetImgGetFrame1() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    var h2 = $("#MyCapture").height();
    var h3 = h1 - h2 - 130;
    $("#divLB").height(h3);
    $("#dImgs").height(h1 - 2);
    $("#dPage").height(h1 - 73);
    $("#viewer").height(h1 - 12).width(w1 - 492);
}

function SetImgGetFrame1_2() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    var h2 = $("#EtOcxEx").height();
    var h3 = h1 - h2 - 130;
    $("#divLB").height(h3);
    $("#dImgs").height(h1 - 2);
    $("#dPage").height(h1 - 73);
    $("#viewer").height(h1 - 12).width(w1 - 492);
}

function SetImgGetFrame1_3() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    //var h2 = $("#dBase").height();
    var h3 = h1 - 90;
    $("#divLB").height(h3);
    $("#dImgs").height(h1 - 2);
    $("#dPage").height(h1 - 73);
    $("#viewer").height(h1 - 12).width(w1 - 492);
}

function SetImgGetFrame1_4() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    //var h2 = $("#dBase").height();
    var h3 = h1 - 90;
    $("#divLB").height(h3);
    $("#dImgs").height(h1 - 2);
    $("#dPage").height(h1 - 73);
    $("#viewer").height(h1 - 12).width(w1 - 492);
}

function SetImgGetFrame2() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    var h2 = $("#MyCapture").height();
    var h3 = h1 - h2 - 140;

    $("#dPage").height(h1 - 150);
    $("#divLB").height(h3);
    $("#viewer").height(h1 - 12).width(w1 - 335);
}

function SetImgGetFrame3() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    $("#divLB").height(h1 - 92);
    $("#dPage").height(h1 - 78);
    $("#viewer").height(h1 - 12).width(w1 - 492);
}

function SetVolumeDir1() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    var h2 = $("#dSearch").height();
    var h3 = $("#bodyDir").height();
    var h4 = h1 - h2 - 298;
    var h5 = h1 - 50;
    $("#dPage").height(h4);
    $("#dRight").height(h5);
    $("#viewer").height(h1 - 10);
}

function SetVolumeDir2() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    var h2 = $("#dSearch").height();
    var h3 = $("#bodyDir").height();
    var h4 = h1 - h2 - 258;
    var h5 = h1 - 50;
    $("#dPage").height(h4);
    $("#dRight").height(h5);
    $("#viewer").height(h1 - 10);
}

function SetVolumeDir10() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    var h2 = $("#dSearch").height();
    var h3 = $("#bodyDir").height();
    var h4 = h1 - h2 - 258;
    var h5 = h1 - 50;
    $("#dPage").height(h4);
    $("#dRight").height(h5);
    $("#viewer").height(h1 - 10);
}

function SetImageSon() {
    var w1 = GetWidth();
    var h1 = GetHeight();
    var h2 = h1 - 190;
    var w2 = w1 - $("#dInfo").width() - 31;
    $("#dInfo").height(h2);
    $("#dImg").height(h2);
}

function SetSeeImage() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    var h2 = $("#divLB").height();

    $(".tab-content").height(h1 - h2 - 97);
    $("#dRight").height(h1 - 15);
    $("#viewer").height(h1 - 10).width(w1 - 320);
}

function SetTreStatistics() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    $("#dImg1,#dImg2,#dImg3,#dImg4,#dImg5,#dImg6,#dImg7,#dImg8,#dImg9,#dImg10,#dImg11,#dImg12,#dImg13,#dImg14").height(h1 - 160);
}

function SetCaseStatistics() {
    var w1 = GetWidth();
    var h1 = GetHeight();

    $("#dImg1,#dImg2,#dImg3,#dImg4,#dImg5,#dImg6,#dImg7,#dImg8,#dImg9,#dImg10,#dImg11,#dImg12,#dImg13,#dImg14,#dImg15,#dImg16,#dImg17").height(h1 - 192);
}


var speed = 300;//滚动速度

//回到顶部
function ToTop() {
    $('html,body').animate({
        scrollTop: '0px'
    }, speed);
}

//回到底部
function ToBottom() {
    var h = document.getElementById("form1").clientHeight;
    $('html,body').animate({
        scrollTop: h + 'px'
    }, speed);
}





//获取地址栏参数的值
function QueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}

//给null默认值
function SetNull(ParStr) {
    if (ParStr == null) {
        return "";
    }
    else {
        return ParStr;
    }
}

//页面打印
function PrintPage() {
    if (confirm("请在首选项中选择横向布局打印!")) {
        window.print();
    }
}

function SetPublicHotKey() {
    document.onkeyup = function (e) {
        var keyCode = e.keyCode;
        var href = location.href.toLowerCase();//当前页面的地址
        var parentHref = window.top.location.href.toLowerCase();//上级页面的地址
        //打开快捷键设置页面
        if (keyCode == 119 && (parentHref.indexOf("/scan1/") != -1 || parentHref.indexOf("/scan2/") != -1) && (href == parentHref || parentHref.indexOf("/ImgGet.aspx".toLowerCase()) != -1)) {
            window.top.showPage('用户自定义设置', '/HotKey.aspx', 800, 550, false);
            return false;
        }
        //删除确定
        if ($("#confirmModal").length > 0 && keyCode == 13) {
            $("#btnOk").click();
            return false;
        }
    }
}


//查看图像信息
function ShowImgInfo() {
    DataLoading();
    var _imgSrc = $("#viewer img").attr("src");
    $.ajax({
        type: "post",
        url: "/ashx/EditData.ashx",
        dataType: "json",
        async: true,
        data: { type: "GetImgInfo", imgSrc: _imgSrc },
        success: function (msg) {
            if (msg.result == 1) {
                var htmlStr = "<table class=\"table table-bordered\" style=\"width:600px;margin:20px auto;\">";
                htmlStr += "<colgroup><col style=\"width: 110px;\" /><col style=\"width: 110px;\" /><col style=\"width: 120px;\" /><col style=\"width: 160px;\" /></colgroup>";
                htmlStr += "<tr><td class=\"text-center\"><b>图片名称：</b></td><td colspan=\"3\">" + msg.PName + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>图片宽度：</b></td><td colspan=\"3\">" + msg.ImgWidth + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>图片高度：</b></td><td colspan=\"3\">" + msg.ImgHeight + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>水平分辨率：</b></td><td colspan=\"3\">" + msg.XResolution + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>垂直分辨率：</b></td><td colspan=\"3\">" + msg.YResolution + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>文件大小：</b></td><td colspan=\"3\">" + msg.FileLen + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>扫描人：</b></td><td>" + msg.UserName1 + "</td><td class=\"text-center\"><b>扫描时间：</b></td><td>" + msg.AddTime1 + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>排序人：</b></td><td>" + msg.UserName2 + "</td><td class=\"text-center\"><b>排序时间：</b></td><td>" + msg.AddTime2 + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>补扫人：</b></td><td>" + msg.UserName5 + "</td><td class=\"text-center\"><b>补扫时间：</b></td><td>" + msg.AddTime5 + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>美化人：</b></td><td>" + msg.UserName3 + "</td><td class=\"text-center\"><b>美化时间：</b></td><td>" + msg.AddTime3 + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>全检人：</b></td><td>" + msg.UserName4 + "</td><td class=\"text-center\"><b>全检时间：</b></td><td>" + msg.AddTime4 + "</td></tr>";

                htmlStr += "<tr><td class=\"text-center\"><b>封面录入人：</b></td><td>" + msg.UserName6 + "</td><td class=\"text-center\"><b>封面录入时间：</b></td><td>" + msg.AddTime6 + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>卷内目录录入人：</b></td><td>" + msg.UserName7 + "</td><td class=\"text-center\"><b>卷内目录录入时间：</b></td><td>" + msg.AddTime7 + "</td></tr>";
                htmlStr += "</table>";

                OpenLayer("图像信息", htmlStr);
            }
            else if (msg.result == 2) {
                var htmlStr = "<table class=\"table table-bordered\" style=\"width:560px;margin:20px auto;\">";
                htmlStr += "<colgroup><col style=\"width: 100px;\" /><col style=\"width: 180px;\" /><col style=\"width: 100px;\" /><col style=\"width: 180px;\" /></colgroup>";
                htmlStr += "<tr><td class=\"text-center\"><b>图片名称：</b></td><td colspan=\"3\">" + msg.PName + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>图片宽度：</b></td><td colspan=\"3\">" + msg.ImgWidth + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>图片高度：</b></td><td colspan=\"3\">" + msg.ImgHeight + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>水平分辨率：</b></td><td colspan=\"3\">" + msg.XResolution + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>垂直分辨率：</b></td><td colspan=\"3\">" + msg.YResolution + "</td></tr>";
                htmlStr += "<tr><td class=\"text-center\"><b>文件大小：</b></td><td colspan=\"3\">" + msg.FileLen + "</td></tr>";
                htmlStr += "</table>";

                OpenLayer("图像信息", htmlStr);
            }
            else {
                window.top.showTip(msg.errMsg, 4, 0);//输出错误信息
            }
            $("#htmlTip").remove();
        }
    });
}

function OpenLayer(_title, _content) {
    window.top.layer.open({
        type: 1
        , title: false //不显示标题栏
        , closeBtn: false
        , shadeClose: true
        , area: '600px;'
        , shade: 0.8
        , id: 'LAY_layuipro' //设定一个id，防止重复弹出
        , resize: false
        , btnAlign: 'c'
        , moveType: 1 //拖拽模式，0或者1
        , content: _content
    });
}


////屏蔽浏览器原有快捷键
//document.addEventListener('keydown', function (e) {
//    var href = location.href.toLowerCase();
//    if (href.indexOf("/HotKey.aspx".toLowerCase()) != -1) {
//        e.preventDefault();
//    }
//    if (e.keyCode == 112) {
//        e.preventDefault();
//    }
//    return false;
//}, false);


function LookFile(FilePath, FileExt) {
    if (FileExt == ".pdf") {
        window.open("/js/plugins/pdfjs/web/viewer.html?file=" + FilePath);
    }
    else if (FileExt == ".jpg" || FileExt == ".jpeg" || FileExt == ".png" || FileExt == ".gif" || FileExt == ".bmp") {
        window.open("/FileLook/LookImage.aspx?file=" + FilePath);
    }
    else {
        window.top.showTip("暂不支持此类文件的在线查看！", 4, 0);//输出错误信息
    }
}

//设置动画
function SetAnimate() {
    var len = $("div[class='wrapper wrapper-content animated']").length;
    if (len > 0) {
        //var arr = ["fadeInDown", "fadeIn", "fadeInLeft", "fadeInRight", "fadeInUp", "flipInX", "bounceIn"];
        var arr = ["fadeIn"];
        var index = Math.floor((Math.random() * arr.length));
        $("div[class='wrapper wrapper-content animated']").hide().addClass(arr[index]).show();
    }
}

//特殊字符转义
function htmlEncode(str) {
    var s = "";
    if (str.length === 0) {
        return "";
    }
    s = str.replace(/#/g, "%23");//转义#字符
    return s;
}

// 对Date的扩展，将 Date 转化为指定格式的String  
// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符，  
// 年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字)  
// 例子：  
// (new Date()).Format("yyyy-MM-dd HH:mm:ss.S") ==> 2006-07-02 08:09:04.423
// (new Date()).Format("yyyy-M-d HH:m:s.S")   ==> 2006-7-2 8:9:4.18
Date.prototype.Format = function (fmt) { //author: meizz  
    var o = {
        "M+": this.getMonth() + 1,         //月份  
        "d+": this.getDate(),          //日  
        "H+": this.getHours(),          //小时  
        "m+": this.getMinutes(),         //分  
        "s+": this.getSeconds(),         //秒  
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度  
        "S": this.getMilliseconds()       //毫秒  
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}

//时间格式转换
//yyyy-MM-dd HH:mm:ss
function DateFormatter(value, row, index) {
    if (value != '' && value != null) {
        var newdate = new Date(value);
        return newdate.Format("yyyy-MM-dd HH:mm:ss");
    }
    else {
        return "-";
    }
}

String.prototype.replaceAll = function (FindText, RepText) {
    regExp = new RegExp(FindText, "g");
    return this.replace(regExp, RepText);
}

//当字数超过10,悬浮
function operateOpinionFormatter(value, row, index) {
    if (value.length > 10) {
        return "<span title='" + value + "'>" + value.substring(0, 10) + "..." + "</span>";
    } else {
        return "<span title='" + value + "'>" + value.substring(10, value.length) + "</span>";
    }
}

//浏览器模式判断
function browserMode() {
    if (window.navigator.userAgent.indexOf('AppleWebKit') != -1) {
    }
    else {
        showTip("你的浏览器不是极速模式请切换成极速模式!", 2);
    }
}